package org.zoomdev.zoom.aop;

import java.lang.reflect.Method;

/**
 * 拦截器
 * <pre>
 * public class LogInterceptor implements Interceptor {
 *
 *     @Override
 *     public Object intercept(Invoker invoker, Method method, Object target, Object[] args) throws Throwable {
 *         System.out.println("before invoke");
 *         try{
 *             return invoker.invoke(target, args);
 *         }finally {
 *             System.out.println("after invoke");
 *         }
 *     }
 * }
 * </pre>
 */
public interface Interceptor {

    /**
     * @param invoker 执行器
     * @param method  原方法
     * @param target  原对象
     * @param args    调用参数
     * @return
     * @throws Throwable
     */
    Object intercept(Invoker invoker,
                     Method method,
                     Object target,
                     Object[] args) throws Throwable;
}
